//
//  CCSubTagCell.m
//  BuDeJie
//
//  Created by demoncraz on 2017/2/11.
//  Copyright © 2017年 demoncraz. All rights reserved.
//

#import "CCSubTagCell.h"
#import <UIImageView+WebCache.h>

@interface CCSubTagCell ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;

@property (weak, nonatomic) IBOutlet UIImageView *headImageView;



@end

@implementation CCSubTagCell


- (void)setItem:(CCSubTagItem *)item {
    _item = item;
    self.titleLabel.text = item.theme_name;
    
    [self resolveNumber];
    
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:item.image_list]];
    
}

- (void)resolveNumber {
    //处理一下订阅数量的数字
    NSInteger subNumber = [self.item.sub_number integerValue];
    
    if (subNumber >= 10000) {
        self.subTitleLabel.text = [NSString stringWithFormat:@"%.1f万人已订阅", subNumber / 10000.0];
    } else {
        self.subTitleLabel.text = [NSString stringWithFormat:@"%zd人已经订阅", subNumber];
    }
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    //图片圆角
    self.headImageView.layer.cornerRadius = self.headImageView.frame.size.width * 0.5;
    self.headImageView.layer.masksToBounds = YES;
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
